#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=110;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL col[maxn];
LL dp[maxn][maxn][maxn];
LL w[maxn][maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL n,m,k;cin>>n>>m>>k;
  for(LL i=1;i<=n;i++) cin>>col[i];
  for(LL i=1;i<=n;i++){
    for(LL j=1;j<=m;j++){
        cin>>w[i][j];
    }
  }
  memset(dp,0x3f,sizeof(dp));
  for(LL p=1;p<=m;p++){
    if(col[1]==0){
        dp[1][1][p]=w[1][p];
    }
    else if(col[1]){
        if(p==col[1]) dp[1][1][p]=0;
        else dp[1][1][p]=0x3f3f3f3f3f3f3f3f;
    }
    dp[0][0][p]=0;
  }

  for(LL i=2;i<=n;i++){
    for(LL j=1;j<=i;j++){
        if(col[i]!=0){
            if(col[i-1]==col[i]){
                dp[i][j][col[i]]=min(dp[i-1][j-1][col[i]]+0,dp[i][j][col[i]]);
            }
            else if(col[i-1]!=0&&col[i-1]!=col[i]){
                dp[i][j][col[i]]=min(dp[i-1][j-1][col[i-1]]+0,dp[i][j][col[i]]);
            }
            else{
                for(LL k1=1;k1<=m;k1++){
                    if(k1!=col[i]){
                        dp[i][j][col[i]]=min(dp[i-1][j-1][k1]+0,dp[i][j][col[i]]);
                    }
                    else if(k1==col[i]){
                        dp[i][j][col[i]]=min(dp[i-1][j][k1]+0,dp[i][j][col[i]]);
                    }
                }
            }
            continue;
        }
        for(LL k1=1;k1<=m;k1++){
            for(LL k2=1;k2<=m;k2++){
                if(k1!=k2){
                    dp[i][j][k2]=min(dp[i-1][j-1][k1]+w[i][k2],dp[i][j][k2]);
                }
                else if(k1==k2){
                    dp[i][j][k2]=min(dp[i-1][j][k1]+w[i][k2],dp[i][j][k2]);
                }
            }
        }
    }
  }
/*
  for(LL i=1;i<=n;i++){
    for(LL j=1;j<=i;j++){
        for(LL k=1;k<=m;k++){
            cout<<"dp["<<i<<"]["<<j<<"]"<<"["<<k<<"]"<<"="<<dp[i][j][k]<<"    ";
        }
        cout<<"\n";
    }
  }*/

  LL ans=1e18;
  for(LL p=1;p<=m;p++){
    ans=min(ans,dp[n][k][p]);
  }
  if(ans==1e18){
    cout<<"-1"<<"\n";
  }
  else cout<<ans<<"\n";
return 0;
}
